<template>
  <div class="photoinfo_container">
    <h1>{{ info.title }}</h1>
    <p>
      <span>发表时间：{{ info.add_time|dataFormat }}</span>
      <span>点击次数： {{ info.click }}次</span>
    </p>
    <hr>
    <div class="img">
      <img
        class="preview-img"
        v-for="(item, index) in list"
        :src="item.src"
        height="100"
        @click="$preview.open(index, list)"
        :key="item.src"
      >
    </div>
    <div class="info_content" v-html="info.content"></div>
    <comments :id="this.id"></comments>
    <hr>
  </div>
</template>
<script>
import comments from "../subcomponents/comments.vue";
export default {
  created() {
    this.getData();
    this.getImg();
  },
  data() {
    return {
      id: this.$route.params.id,
      info: [],
      list: []
    };
  },
  methods: {
    getData() {
      this.$http.get("api/getimageInfo/" + this.id).then(data => {
        if (data.body.status === 0) {
          console.log(data.body.message[0]);
          this.info = data.body.message[0];
        }
      });
    },
    getImg() {
      this.$http.get("api/getthumimages/" + this.id).then(data => {
        if (data.body.status === 0) {
          data.body.message.forEach(item => {
            (item.w = 600), (item.h = 400);
          });
          this.list = data.body.message;
          console.log(this.slide1);
        }
      });
    },
    handleClose() {
      console.log("close event");
    }
  },
  components: {
    comments: comments
  }
};
</script>
<style lang="scss" scoped>
.photoinfo_container {
  padding: 10px 5px;
  h1 {
    text-align: center;
    font-size: 15px;
    color: #26a2ff;
    margin-bottom: 10px;
  }
  p {
    display: flex;
    justify-content: space-between;

    span {
      font-size: 12px;
      color: #999;
    }
  }
  .info_content {
    line-height: 30px;
    font-size: 14px;
  }
  .img {
    img {
      margin: 10px;
    }
  }
}
</style>
